package com.cnswhy.cloud.server.merchant.controller.shop;

import com.cnswhy.cloud.server.core.dao.ShopProductSpecMapper;
import com.cnswhy.cloud.server.core.dto.ShopSpecValuePageDTO;
import com.cnswhy.cloud.server.core.entity.ShopProductSpec;
import com.cnswhy.cloud.server.core.dto.ShopProductSpecSaveDTO;
import com.cnswhy.cloud.server.core.dto.ShopProductSpecUpdateDTO;
import com.cnswhy.cloud.server.core.dto.ShopProductSpecPageDTO;
import com.cnswhy.cloud.server.core.entity.ShopSpecValue;
import com.cnswhy.cloud.server.core.service.ShopProductSpecService;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.cnswhy.cloud.common.core.base.controller.SuperController;
import com.cnswhy.cloud.common.core.base.R;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
//import com.github.zuihou.security.annotation.PreAuth;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * 商品规格关系表
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-23
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/shopProductSpec")
@Api(value = "ShopProductSpec", tags = "商品规格关系表")
//@PreAuth(replace = "shopProductSpec:")
public class ShopProductSpecController extends SuperController<ShopProductSpecService, Long, ShopProductSpec, ShopProductSpecPageDTO, ShopProductSpecSaveDTO, ShopProductSpecUpdateDTO> {
    @Autowired
    ShopProductSpecMapper shopProductSpecMapper;
   /*
    @PostMapping("/queryProductSpecValueList")
    public R<List<>> queryProductSpecValueList(@RequestBody ShopProductSpecPageDTO shopProductSpecPageDTO) {
        //List<ShopProductSpec> shopProductSpecList = shopProductSpecMapper.queryProductSpecValueList(shopProductSpecPageDTO.getProductId());

        return success(shopProductSpecList);
    }*/
    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<ShopProductSpec> shopProductSpecList = list.stream().map((map) -> {
            ShopProductSpec shopProductSpec = ShopProductSpec.builder().build();
            return shopProductSpec;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(shopProductSpecList));
    }
}
